<template>
  <div>
    <el-dialog
      title="题目审核"
      :visible.sync="checkShow"
      width="40%"
    >
      <el-form ref="form" :model="formData" :rules="rules">
        <el-form-item prop="chkState">
          <el-radio v-model="formData.chkState" :label="1">通过</el-radio>
          <el-radio v-model="formData.chkState" :label="2">拒绝</el-radio>
        </el-form-item>

        <br>
        <br>

        <el-form-item prop="chkRemarks">
          <el-input
            v-model="formData.chkRemarks"
            type="textarea"
            :rows="5"
            placeholder="请输入审核意见"
          />
        </el-form-item>

      </el-form>

      <span slot="footer">
        <el-button @click=" checkShow= false">取消</el-button>
        <el-button type="primary" @click="btnOk">确认</el-button>
      </span>
    </el-dialog>

  </div>
</template>

<script>
import { getCheckInfo } from '@/api/choice'
export default {
  name: 'CheckDialog',
  data() {
    return {
      checkShow: false,
      formData: {
        chkState: 1,
        chkRemarks: ''
      },
      rules: {
        chkState: [
          { required: true, message: '请选择审核意见', trigger: 'change' }
        ],
        chkRemarks: [
          { required: true, message: '请输入审核意见', trigger: 'blur' }
        ] }
    }
  },
  methods: {
    async  btnOk() {
      try {
        await this.$refs.form.validate()
        await getCheckInfo(this.formData)
        this.$message.success('审核成功')
      } catch (error) {
        console.log(error)
      }
      this.checkShow = false
      this.$emit('upload')
    }
  }
}
</script>

<style>

</style>
